package com.ztgf.order.api.client;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.order.models.bo.LogisticsEditBO;
import com.ztgf.order.models.bo.OrderAfterShipSaveBO;
import com.ztgf.order.models.service.IOrderAfterShipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * author: chenyu.wang
 * date: 2020-06-30 16:24
 * Description:
 */
@RestController
@RequestMapping("/api/orderAfterShip")
@Api(value = "OrderAfterShipApiController", tags = "售后订单发货表Api接口")
public class OrderAfterShipApiController {

    @DubboReference
    private IOrderAfterShipService iOrderAfterShipService;

    @PostMapping(value = "/addOrderShip")
    @ApiOperation(value = "售后订单发货接口", notes = "售后订单发货接口")
    public Result addOrderShip(OrderAfterShipSaveBO shipSaveBO) {
        return iOrderAfterShipService.saveOrderShip(shipSaveBO);
    }

    @PostMapping(value = "/queryOrderShipMsg")
    @ApiOperation(value = "根据售后发货表id查询发货信息", notes = "根据售后发货表id查询发货信息")
    public Result queryOrderShipMsg(Long id) {
        if (id != null) {
            iOrderAfterShipService.queryById(id);
            return new Result<>();
        }
        return new Result<>(CodeEnum.FAIL_100002);
    }

    @PostMapping(value = "/updateLogistics")
    @ApiOperation(value = "修改物流信息（重新发货）", notes = "修改物流信息（重新发货）")
    public Result updateLogistics(LogisticsEditBO saveBO) {
        return iOrderAfterShipService.updateLogistics(saveBO);
    }
}
